package com.godGuang.payment.controller;

import com.godGuang.common.core.domain.Result;
import com.godGuang.payment.service.AliPayService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

@RestController
@Log4j2
public class PayController {
    @Autowired
    private AliPayService aliPayService;

    @GetMapping("/pay/{money}")
    public Result pay(@PathVariable Integer money) {
        String pay = aliPayService.Pay(money);
        return Result.success(pay);
    }
    //@GetMapping("pay2")
    //public void pay2(@RequestParam BigDecimal money) {
    //     aliPayService.Pay2(money);
    //
    //}

    @GetMapping("tradeQuery")
    public Result tradeQuery(@RequestParam String orderNumber) {
        return Result.success(aliPayService.tradeQuery(orderNumber));
    }

    @PostMapping("tradeClose")
    public Result tradeClose() {
        aliPayService.tradeClose();
        return Result.success();
    }

    @PostMapping("tradeRefund")
    public Result tradeRefund() {
        aliPayService.tradeRefund();
        return Result.success();
    }

    @GetMapping("tradeRefundQuery")
    public Result tradeRefundQuery() {
        aliPayService.tradeRefundQuery();
        return Result.success();
    }

    @PostMapping("/tradeNotifyUrl")
    public Result tradeNotifyUrl() {
        aliPayService.tradeNotifyUrl();
        return Result.success();
    }

    @GetMapping("/tradeReturn")
    public Result tradeReturn() {
        aliPayService.tradeReturn();
        return Result.success();
    }
}
